<%@page import="com.farm.configer.form.ConfigerFormGenerator"%>
<%@page import="java.util.Map.Entry"%>
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/view/conf/farmtag.tld" prefix="PF"%>
<!--配置表单表单-->
<div class="easyui-layout" data-options="fit:true">
	<div class="TableTitle" data-options="region:'north',border:false">
		<span class="label label-primary">${configer.model } <c:if
				test="${pageset.operateType==1}">新增${JSP_Messager_Title}记录</c:if> <c:if
				test="${pageset.operateType==2}">修改${JSP_Messager_Title}记录</c:if> <c:if
				test="${pageset.operateType==0}">浏览${JSP_Messager_Title}记录</c:if>
		</span>
	</div>
	<div data-options="region:'center'">
		<form id="dom_formConfigerform">
			<input type="hidden" id="entity_id" name="id" value="${entity.id}">
			<input type="hidden" id="entity_configerid" name="configerid"
				value="${configer.id}">
			<table class="editTable">
				<c:if test="${configer.model=='NONE' }">
					<tr>
						<td class="title">名称:</td>
						<td><input type="text" style="width: 120px;"
							class="easyui-validatebox"
							data-options="required:true,validType:[,'maxLength[64]']"
							id="entity_name" name="name" value="${entity.name}"></td>
						<td class="title">编码:</td>
						<td><input type="text" style="width: 120px;"
							class="easyui-validatebox"
							data-options="required:true,validType:[,'maxLength[64]']"
							id="entity_code" name="code" value="${entity.code}"></td>
					</tr>
					<tr>
						<td class="title">模型:</td>
						<td><select style="width: 120px;" id="entity_model"
							name="model" val="${entity.model}">
								<%
								for (Entry<String, String> node : ConfigerFormGenerator.getFormModels().entrySet()) {
								%>
								<option value="<%=node.getKey()%>"><%=node.getValue()%></option>
								<%
								}
								%>
								<!-- 内部参数 -->
						</select></td>
						<td class="title">校验:</td>
						<td><select style="width: 120px;" id="entity_valid"
							name="valid" val="${entity.valid}">
								<option value="none">无限制</option>
						</select></td>
					</tr>
					<tr id="entity_enums_tr">
						<td class="title">枚举项:</td>
						<td colspan="3"><input type="text" style="width: 420px;"
							class="easyui-validatebox"
							data-options="validType:['maxLength[512]']"
							id="entity_enums" name="enums"
							value="${entity.enums}"><br/>逗号分隔多个枚举项，或直接填写数据字典key</td>
					</tr>
					<tr id="entity_innercode_tr">
						<td class="title">参数名称:</td>
						<td colspan="3"><input type="text" style="width: 420px;"
							class="easyui-validatebox"
							data-options="required:true,validType:['maxLength[128]']"
							id="entity_innercode" name="innercode"
							value="${entity.innercode}"></td>
					</tr>
					<tr>
						<td class="title">排序:</td>
						<td><input type="text" style="width: 120px;"
							class="easyui-validatebox"
							data-options="required:true,validType:['integer','maxLength[16]']"
							id="entity_sort" name="sort" value="${entity.sort}"></td>
						<td class="title"></td>
						<td></td>
					</tr>
					<tr>
						<td class="title">备注:</td>
						<td colspan="3"><textarea rows="2" style="width: 420px;"
								class="easyui-validatebox"
								data-options="validType:[,'maxLength[64]']" id="entity_pcontent"
								name="pcontent">${entity.pcontent}</textarea></td>
					</tr>
				</c:if>
				<c:if test="${configer.model!='NONE' }">
					<tr>
						<td class="title">名称:</td>
						<td>${entity.name}</td>
						<td class="title">编码:</td>
						<td>${entity.code}</td>
					</tr>
					<c:if test="${entity.model=='inner'}">
						<tr>
							<td class="title">内部参数:</td>
							<td colspan="3"><input type="text" style="width: 420px;"
								class="easyui-validatebox"
								data-options="required:true,validType:['key','maxLength[64]']"
								id="entity_innercode" name="innercode"
								value="${entity.innercode}"></td>
						</tr>
					</c:if>
				</c:if>
			</table>
		</form>
	</div>
	<div data-options="region:'south',border:false">
		<div class="div_button" style="text-align: center; padding: 4px;">
			<c:if test="${pageset.operateType==1}">
				<a id="dom_add_entityConfigerform" href="javascript:void(0)"
					iconCls="icon-save" class="easyui-linkbutton">增加</a>
			</c:if>
			<c:if test="${pageset.operateType==2}">
				<a id="dom_edit_entityConfigerform" href="javascript:void(0)"
					iconCls="icon-save" class="easyui-linkbutton">修改</a>
			</c:if>
			<a id="dom_cancle_formConfigerform" href="javascript:void(0)"
				iconCls="icon-cancel" class="easyui-linkbutton"
				style="color: #000000;">取消</a>
		</div>
	</div>
</div>
<script type="text/javascript">
	var submitAddActionConfigerform = 'configerform/add.do';
	var submitEditActionConfigerform = 'configerform/edit.do';
	var currentPageTypeConfigerform = '${pageset.operateType}';
	var submitFormConfigerform;
	$(function() {
		//表单组件对象
		submitFormConfigerform = $('#dom_formConfigerform').SubmitForm({
			pageType : currentPageTypeConfigerform,
			grid : gridConfigerform,
			currentWindowId : 'winConfigerform'
		});
		//关闭窗口
		$('#dom_cancle_formConfigerform').bind('click', function() {
			$('#winConfigerform').window('close');
		});
		//提交新增数据
		$('#dom_add_entityConfigerform').bind('click', function() {
			submitFormConfigerform.postSubmit(submitAddActionConfigerform);
		});
		//提交修改数据
		$('#dom_edit_entityConfigerform').bind('click', function() {
			submitFormConfigerform.postSubmit(submitEditActionConfigerform);
		});
		init_entity_model();
		$('#entity_model').change(function() {
			init_entity_model();
		});
	});

	function init_entity_model() {
		if ($('#entity_model').val() == 'inner') {
			$('#entity_innercode_tr').show();
			$('#entity_innercode').validatebox({
				required : true
			});
		} else {
			$('#entity_innercode_tr').hide();
			$('#entity_innercode').validatebox({
				required : false
			});
		}
		
		
		if ($('#entity_model').val() == 'select') {
			$('#entity_enums_tr').show();
			$('#entity_enums').validatebox({
				required : true
			});
		} else {
			$('#entity_enums_tr').hide();
			$('#entity_enums').validatebox({
				required : false
			});
		}
	}
//-->
</script>